package com.guomao.iodemos;

import java.io.*;

public class DemoD {


    public static void main(String[] args) {


//        pw();

        ps();

    }

    private static void ps() {

//        new PrintStream()

//        PrintStream out = System.out;

        try {
            PrintStream ps = new PrintStream(new FileOutputStream("abc.txt"));
            System.setOut(ps);
            System.out.println("abc");
            System.out.println("123");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } finally {
        }
    }

    private static void pw() {
        try {
            PrintWriter pw = new PrintWriter(new FileWriter("pw.txt"));


            pw.println("Hello World");

            pw.printf("这是一个格式化的数字: %.2f%n", 3.14159);

            pw.print("Hello World not ln");

            pw.flush();
            pw.close();

        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
        }
    }

}
